﻿
namespace ReadSolutionContents
{
    /// <summary>
    /// Wildcard characters contained in file paths.
    /// </summary>
    internal static class Wildcard
    {
        /// <summary>
        /// Wildcard characters.
        /// 
        /// </summary>
        private static readonly string[] Wildcards = new string[2]
    {
      "*",
      "?"
    };
        /// <summary>
        /// Zero or more characters.
        /// </summary>
        public const string Asterisk = "*";

        /// <summary>
        /// Zero or one character.
        /// </summary>
        public const string Question = "?";

        static Wildcard()
        {
        }

        /// <summary>
        /// Add asterisk wildcard character to given file extension.
        /// </summary>
        /// <param name="fileExtension">String representing file extension. </param>
        /// <returns>
        /// String representing file extension prefixed with asterisk wildcard character.
        /// </returns>
        public static string AddAsterisk(string fileExtension)
        {
            return "*" + fileExtension;
        }

        /// <summary>
        /// Determine if given file path contains any wildcard characters.
        /// 
        /// </summary>
        /// <param name="filePath">String representing file path.
        ///             </param>
        /// <returns>
        /// True if file path contains any wildcard characters, false otherwise.
        /// 
        /// </returns>
        public static bool HasWildcard(string filePath)
        {
            if (!string.IsNullOrEmpty(filePath))
            {
                foreach (string str in Wildcard.Wildcards)
                {
                    if (filePath.Contains(str))
                        return true;
                }
            }
            return false;
        }
    }
}
